using System.Collections.Generic;
using System.Threading.Tasks;
using MongoDB.Driver;
using Sustainalytics.Synchronization.Interface;
using Sustainalytics.SharedEntities.Corporate;

namespace Sustainalytics.ClientDW.Synchronization.SyncReferenceUniv.ReferenceUniverseLogic
{
    public class ReferenceUniverseCommand
    {
        private readonly IMongoCollection<ReferenceUniverse> referenceUniverseCollection;

        public ReferenceUniverseCommand(IMongoCollection<ReferenceUniverse> referenceUniverseCollection, ILogger logger)
        {
            this.referenceUniverseCollection = referenceUniverseCollection;
        }

        /// <summary>
        /// Delete All Universe Reference except Default one
        /// </summary>
        /// <returns></returns>
        public async Task<DeleteResult> DeleteRecordsAsync()
        {
            var result = await referenceUniverseCollection.DeleteManyAsync(x => x.Name != "Default").ConfigureAwait(false);
            return result;
        }

        public async Task InsertRecordsAsync(IList<ReferenceUniverse> entities)
        {
             await referenceUniverseCollection.InsertManyAsync(entities);
        }
    }
}
